﻿using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using DistributeTransaction.Utils;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.VisualStudio.TestTools.UnitTesting.Web;

namespace DistributeTransaction.Tests
{
    /// <summary>
    ///This is a test class for DBUtilTest and is intended
    ///to contain all DBUtilTest Unit Tests
    ///</summary>
    [TestClass]
    public class DBUtilTest
    {
        private string ConnectionString;

        [TestInitialize]
        public void MyTestInitialize()
        {
            ConnectionString = ConfigurationManager.ConnectionStrings["DatabaseContext"].ConnectionString;
        }

        [TestMethod]
        public void EscapeLikeValueTest()
        {
            string valueWithoutWildcards = "~ ( ) # \\ / = > < + - * % & | ^ ' \"[]";
            string expected = "[~] [(] [)] [#] [\\] [/] [=] [>] [<] [+] [-] [*] [%] [&] [|] [^] '' [\"][[][]]";
            string actual = DBUtil.EscapeLikeValue(valueWithoutWildcards); 
            
            Assert.AreEqual(expected, actual);
        }

        
        public void ExecuteReaderTest()
        {
            string sql = string.Empty; // TODO: Initialize to an appropriate value
            string ConnectString = string.Empty; // TODO: Initialize to an appropriate value
            ReceivedDataEventHandler readDataEvent = null; // TODO: Initialize to an appropriate value
            SqlParameter[] sqlParams = null; // TODO: Initialize to an appropriate value
            bool expected = false; // TODO: Initialize to an appropriate value
            bool actual;
            actual = DBUtil.ExecuteReader(sql, ConnectString, readDataEvent, sqlParams);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }


        public void ExecuteStoreProcedureTest()
        {
            string sql = string.Empty; // TODO: Initialize to an appropriate value
            string ConnectString = string.Empty; // TODO: Initialize to an appropriate value
            SqlParameter[] sqlParams = null; // TODO: Initialize to an appropriate value
            bool expected = false; // TODO: Initialize to an appropriate value
            bool actual;
            actual = DBUtil.ExecuteStoreProcedure(sql, ConnectString, sqlParams);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }


        public void FillDataSetTest()
        {
            string sql = string.Empty; // TODO: Initialize to an appropriate value
            string ConnectString = string.Empty; // TODO: Initialize to an appropriate value
            SqlParameter[] sqlParams = null; // TODO: Initialize to an appropriate value
            DataSet expected = null; // TODO: Initialize to an appropriate value
            DataSet actual;
            actual = DBUtil.FillDataSet(sql, ConnectString, sqlParams);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }


        public void FillDataTableTest()
        {
            string sql = string.Empty; // TODO: Initialize to an appropriate value
            string ConnectString = string.Empty; // TODO: Initialize to an appropriate value
            SqlParameter[] sqlParams = null; // TODO: Initialize to an appropriate value
            DataTable expected = null; // TODO: Initialize to an appropriate value
            DataTable actual;
            actual = DBUtil.FillDataTable(sql, ConnectString, sqlParams);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }


        public void ForamtDateTimeTest()
        {
            object o = null; // TODO: Initialize to an appropriate value
            string expected = string.Empty; // TODO: Initialize to an appropriate value
            string actual;
            actual = DBUtil.ForamtDateTime(o);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }

        public void ForamtStringTest()
        {
            object o = null; // TODO: Initialize to an appropriate value
            string expected = string.Empty; // TODO: Initialize to an appropriate value
            string actual;
            actual = DBUtil.ForamtString(o);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }


        public void RemovePipeLineTest()
        {
            string s = string.Empty; // TODO: Initialize to an appropriate value
            string expected = string.Empty; // TODO: Initialize to an appropriate value
            string actual;
            actual = DBUtil.RemovePipeLine(s);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }


        public void RunSQLCmdTest()
        {
            string sql = string.Empty; // TODO: Initialize to an appropriate value
            string ConnectString = string.Empty; // TODO: Initialize to an appropriate value
            SqlParameter[] sqlParams = null; // TODO: Initialize to an appropriate value
            bool expected = false; // TODO: Initialize to an appropriate value
            bool actual;
            actual = DBUtil.RunSQLCmd(sql, ConnectString, sqlParams);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }

        public void SQLParamsToStringTest()
        {
            SqlParameter[] sqlParams = null; // TODO: Initialize to an appropriate value
            string expected = string.Empty; // TODO: Initialize to an appropriate value
            string actual;
            actual = DBUtil_Accessor.SQLParamsToString(sqlParams);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
    }
}
